CaptureDepth
CaptureDepth ZdepthValue
 
Parameters:

    ZdepthValue = The Z depth to use for the following captured graphic commands
Returns: NONE
 

      CaptureDepth sets the Z depth that any following captured graphics commands will be stored at when captured to the scene buffer. The captured item will be rendered based upon it's depth within the list captured items. Items with a higher depth value are depth before those with lower values.




FACTS:


      * CaptureDepth values must be positive (0 and higher)



Mini Tutorial:


      This example first creates a camera in part 1. Then in the second part it redirects all graphics output to PB's scene buffer. Using the CaptureDepth to control the order of the drawn items



  
  
; ============================
;     Part 1 - Create a Camera
; ============================
  
; create a camera 1.
  CreateCamera 1
  
; Activate the camera Auto Cls
  CameraCls 1,on
  
; Set the Cameras Auto CLS colour
  CameraClsColour 1,RGB(0,255,0)
  
  
; ============================
;     Part 2 - Capture some graphics to the Scene buffer
; ============================
  
; Tell PB to now capture all the following GFX
; commands to the scene buffer rather than draw them
;  immediately
  CaptureToScene
  
; Clear the SceneBuffer
  ClsScene
  
; Tell PB to assign the following captured graphics command
; a scene  DEPTH of 1
  CaptureDepth 1
  
  
; Draw a BLUE circle the Scene
  CircleC 50,50,40,1,RGB(0,0,255)
  
  
; Tell PB to assign the following captured graphics command
; a scene  DEPTH of 20
  CaptureDepth 20
  
; Draw a RED circle the Scene     buffer
  CircleC 70,50,40,1,RGB(255,0,0)
  
  
; Draw the camera and whatever it can see
  DrawCamera 1
  
; Show the user the screen.
  Sync
  
; wait for a key press, before ending
  WaitKey
  
  



     If you test this example, you should notice something interesting occurring. While it simply draws two overlapping Blue & RED circles through a camera. If you look carefully, You'll may have noticed that even while the code renders the BLUE circle first, then the RED circle. The RED circle is actually drawn behind the BLUE circle.




      This occurs because prior to rendering each circle to the scene buffer, the code sets the Capturing Z depth of the following items we about to draw with the CaptureDepth command. If you look closely, the Blue circle is being captured at a depth of 1, while the Red circle is being capture a depth of 20.

      So what the camera does, is first order the items in the scene buffer from highest Z depth to lowest, then renders them in this order (highest to lowest). So items with a higher z depth, will be drawn behind items with a lower Z depth, regardless of what order we capture these drawing requests to the scene buffer in.


 
Related Info: CameraBasics | CaptureToScene | CaptureVis | ClsScene | DrawGFXImmediate | GetCaptureDepth :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com